package day4

import scala.collection.mutable.ArrayBuffer

object Test4_filter {
  def main(args: Array[String]): Unit = {

    var list = List("Alice", "Tom", "Jack", "Abc")
    val list2 = list filter (v => {
      v.startsWith("A")
    })
    println(list2)
    for (elem <- list2) {
      println(elem)
    }


    val arr1 = new ArrayBuffer[(String, Int, Double)]()
    arr1.append(("yy", 22, 57.9))
    arr1.append(("yz", 27, 87.9))
    arr1.append(("yx", 25, 37.9))
    arr1.append(("yt", 23, 97.9))

    /*var arr2 = arr1.map((k:(String,Int,Double)) => {
      var falg = ""
      if (k._3 > 60){
        falg = "及格"
      }else {
        falg = "不及格"
      }
      (k._1,k._2,falg)
    })*/
    var arr2 = arr1.map(k => {
      var falg = ""
      if (k._3 > 60){
        falg = "及格"
      }else {
        falg = "不及格"
      }
      (k._1,k._2,falg)
    })

    for (elem <- arr2) {
      println(elem)
    }

    val arr3 = arr1.filter(v => v._3 >= 60)
    for (elem <- arr3) {
      println(elem)
    }

  }
}
